package com.example.yuejian.yuejian.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;

import com.example.yuejian.yuejian.R;
import com.example.yuejian.yuejian.base.BaseActivity;
import com.example.yuejian.yuejian.base.ModleListener;
import com.example.yuejian.yuejian.bean.EditAddress;
import com.example.yuejian.yuejian.model.UserModel;

public class EditAddressActivity extends BaseActivity {
    private EditText useraddress;
    private Button confirm;
    private  ImageView btn_back;
    private ModleListener<EditAddress>listener =new ModleListener<EditAddress>() {
        @Override
        public void onResponse(EditAddress o) {
            EditAddress res=o;
            if (!"0".equals(res.getRetCode()))
            {
                Toast.makeText(EditAddressActivity.this,res.getRetMsg(),Toast.LENGTH_SHORT).show();
                finish();
            }
            else
            {
                Toast.makeText(EditAddressActivity.this,res.getRetMsg(),Toast.LENGTH_SHORT).show();
            }
        }

        @Override
        public void onFail(String msg) {

        }
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_edit_address);
        back();
        useraddress=(EditText)findViewById(R.id.edit_useraddress);
        confirm=(Button)findViewById(R.id.editaddress_confirm_btn) ;
        Intent intent=getIntent();
        String school=intent.getStringExtra("school");
        useraddress.setText(school);
        confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                UserModel userModel=new UserModel();
                userModel.EditAddress(getUser_id(),useraddress.getText().toString(),listener);
            }
        });
    }
    private void back()
    {
        btn_back=(ImageView)findViewById(R.id.imgBtn_edit_address_back);
        btn_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

    }
}
